package com.rd.student.jike.class1.sunhao.day11;

import java.util.concurrent.locks.ReentrantLock;

public class Test {

    public static void main(String[] args) {

        XianCheng xianCheng = new XianCheng();
        XianCheng xianCheng1 =  new XianCheng();
        xianCheng.setPriority(10);
        xianCheng.start();
        xianCheng1.start();
    }
}

class XianCheng extends Thread{
    ReentrantLock lock = new ReentrantLock();
    public void run(){
        for (int i=0;i<20;i++){
        lock.lock();
        System.out.println(this.getName()+"哈哈");
//        try{
//            Thread.sleep(500);
//        }catch(Exception e){
//            e.printStackTrace();
//        }
        lock.unlock();
        }
    }
}